package com.mgq.algorithm.hash;

import java.util.TreeSet;

/**
 * @author MaGuangQi
 * @date 2021-12-29 10:57
 **/
public class TestHash {
    public static void main(String[] args) {
        TreeSet<Integer> treeSet = new TreeSet<>();
        treeSet.add(2);
        treeSet.add(5);
        treeSet.add(2);
        treeSet.add(3);
        treeSet.add(6);
        for (Integer integer : treeSet) {
            System.out.println(integer);
        }

        //引用类型,必须要实现比较器 Comparable接口,告诉集合按照什么来排序
        TreeSet<Student> students = new TreeSet<>();
        students.add(new Student("张三",2));
        students.add(new Student("李四",5));
        students.add(new Student("赵六",3));
        students.add(new Student("yao",1));
        students.forEach(System.out::println);
    }
}
